import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Queue;

class IntCmp implements Comparator<Integer> {
    @Override
    public int compare(Integer o1, Integer o2) {
        return o2.compareTo(o1);
    }
}

public class Test {

    //最小的前k个数据。
    public int[] smallestK1(int[] arr, int k) {
        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>();
        //O(N*logN)
        for (int i = 0; i < arr.length; i++) {
            priorityQueue.offer(arr[i]);
        }

        //O(K*logN)
        int[] ret = new int[k];
        for (int i = 0; i < k; i++) {
            ret[i] = priorityQueue.poll();
        }
        return ret;
    }



    public static void main(String[] args) {
        //Queue<Integer> priorityQueue = new PriorityQueue<>();

        //PriorityQueue<Integer> priorityQueue = new PriorityQueue<>();

        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>(new IntCmp());
        priorityQueue.offer(11);
        priorityQueue.offer(12);
        System.out.println(priorityQueue.peek());
    }
}
